package org.example.m7_13;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        int[] abc = new int[3];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 3; j++) {
                abc[j] = in.nextInt();
            }
            int min = min(abc[0],abc[1]);
            min = min(abc[2],min);
            int o = abc[1] - min;
            int score = 0;
            if (o > 2){
                score += o - 1;
            }
            score += min * 2;
            System.out.println(score);
        }
    }

    private static int min(int x, int y) {
        return x > y ? y : x;
    }
}
